﻿@using Microsoft.AspNetCore.Identity
<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>@ViewBag.Title</title>
    
    <environment include="Development">
        <link href="~/lib/twitter-bootstrap/css/bootstrap.css" rel="stylesheet" />
    </environment>
    <environment exclude="Development">
        <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.min.css" 
              asp-fallback-href="~/lib/twitter-bootstrap/css/bootstrap.min.css"
              asp-fallback-test-class="sr-only"
              asp-fallback-test-property="position"
              asp-fallback-test-value="absolute"
              rel="stylesheet">
    </environment>
    
    <link href="~/css/site.css" rel="stylesheet" />

</head>
<body>

<div class="container">
    @inject SignInManager<ApplicationUser> SignInManager
    <nav class="navbar navbar-expand-sm bg-dark navbar-dark">
        <a class="navbar-brand" asp-controller="Home" asp-action="Index">
            <img src="~/images/tiger.jpg" width="30" height="30"/>
        </a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div id="collapsibleNavbar" class="collapse navbar-collapse">
            <ul class="navbar-nav">
                <li class="nav-item">
                    <a class="nav-link" asp-controller="Home" asp-action="Index">学生列表</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" asp-controller="Home" asp-action="Create">添加学生</a>
                </li>
                
                @if (SignInManager.IsSignedIn(User) && User.IsInRole("Admin"))
                {
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="False">管理</a>
                        <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
                            <a class="dropdown-item" asp-controller="Admin" asp-action="ListRoles">角色列表</a>
                            <a class="dropdown-item" asp-controller="Admin" asp-action="ListUsers">用户列表</a>
                        </div>
                    </li>
                }
            </ul>
            <ul class="navbar-nav ml-auto">

                @if (SignInManager.IsSignedIn(User))
                {
                    <li class="nav-item">
                        <form asp-controller="Account" asp-action="logout" method="post">
                            <button type="submit" style="width: auto" class="nav-link btn btn-link py-0">注销 @User.Identity.Name</button>
                        </form>
                    </li>
                }
                else
                {
                    <li class="nav-item">
                        <a class="nav-link" asp-controller="Account" asp-action="Register">注册</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" asp-controller="Account" asp-action="Login">登录</a>
                    </li>
                }

            </ul>
        </div>
    </nav>
    @RenderBody()
</div>

<script src="~/lib/jquery/jquery.js" asp-append-version="true"></script>
<script src="~/lib/jquery-validate/jquery.validate.js" asp-append-version="true"></script>
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js" asp-append-version="true"></script>
<script src="~/lib/twitter-bootstrap/js/bootstrap.js" asp-append-version="true"></script>

@if (IsSectionDefined("Scripts"))
{
    @RenderSection("Scripts", required: false)
}

</body>
</html>
